<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title><!--{$title}--></title>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<link rel="stylesheet" href="<!--{$url_prefix}-->css/bootstrap.css" />
<link rel="stylesheet" href="<!--{$url_prefix}-->css/cikonss.css">
<link rel="stylesheet" href="<!--{$url_prefix}-->css/bootstrap-responsive.css" /><!-- 加入后变为响应式布局，去掉变为固定宽度布局 -->
<link rel="stylesheet" href="<!--{$url_prefix}-->css/mallcontent.css" />
<script src="<!--{$url_prefix}-->js/jquery.js"></script>
<script src="<!--{$url_prefix}-->js/bootstrap.js"></script>
<script src="<!--{$url_prefix}-->js/kindeditor/kindeditor-min.js"></script>
<script src="<!--{$url_prefix}-->js/kindeditor/lang/zh_CN.js"></script>
<script src="<!--{$url_prefix}-->js/kindeditor/editor.js"></script>
<!--[if lt IE 9]>
  <script src="<!--{$url_prefix}-->js/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="main">
<div class="container clearfix">
    <!--{foreach from = $commodity_info item = ci}-->
    <div class="mallpic">
        <img src="<!--{$ci.image_url|get_img_url:'commodity'}-->"/>
        <!--{if $next}-->
        <a href="<!--{$url}-->/home/foodcontent/<!--{$next}-->/<!--{$commodity_type}-->/<!--{if empty($type)}-->1<!--{else}--><!--{$type}--><!--{/if}-->">
            <p class="graphleft">
            <i class="icon-angle-right">&lt;</i>
            </p>
        </a>
        <!--{/if}-->
        <!--{if $last}-->
        <a href="<!--{$url}-->/home/foodcontent/<!--{$last}-->/<!--{$commodity_type}-->/<!--{if empty($type)}-->1<!--{else}--><!--{$type}--><!--{/if}-->">
            <p class="graphright">
            <i class="icon-angle-left">&gt;</i>
            </p>
        </a>
        <!--{/if}-->
    </div>
    <div class="mallxx clearfix">
        <h4><!--{$ci.name}--></h4>
        <p>
        <em>￥<!--{$ci.price}--></em>
        <i id="activity_content"></i>
        </p>

        <div class="error_pop"></div>
        <div id="content" style="display:none;"><!--{$ci.descript}--></div>
        <p class="right"><!-- href="#review"-->
            <a href="#review" id="replys">
                <span class="icon icon-small"><span class="icon-comment-text"></span></span>
                <b id="review_btn" >评论</b>
            </a>
        </p>
    </div>
    <!--{/foreach}-->
    <!--{if $review_info}-->
    <div class="comment" id="comment">
        <span class="selected"></span>
        <ul>
    <!-- 手机:$ri.phone_number|view_phone-->
            <!--{foreach from = $review_info item = ri}-->
            <!--{if $ri.content}-->
            <li>
            <p><em class="left"><b><!--{urldecode($ri.name)}--></b>说:</em></p>
            <p><!--{$ri.content}--></p>
            <p><i class="right"><!--{substr($ri.created,5,11)}--></i></p>
            </li>
            <!--{/if}-->
            <!--{/foreach}-->
        </ul>
    </div>
    <!--{/if}-->
    <!--弹出文本输入框-->
    <input type="hidden" value="commodity" id="review_type"/>
    <input type="hidden" name="review_shop" id="review_shop" value="<!--{$id_shop}-->"/>
    <input type="hidden" name="review_business" id="review_business" value="<!--{$id_business}-->"/>
    <input type="hidden" name="review_id" id="review_id" value="<!--{$id_commodity}-->"/>
        <input type="hidden" value="<!--{$id_open}-->" id="id_open"/>
        <input type="hidden" name="can_review" id="can_review" value="<!--{$can_review}-->"/>
        <input type="hidden" name="nick_name" id="nick_name" value="<!--{$nick_name}-->"/>

    <!--{include file="review.html"}-->
</div>

<footer>powered by <a href="http://www.it008.com" target="_blank">赏金猎人</a></footer>
</div>
<script type="text/javascript">
    var content = $('#content').html();
    var html_audio = content.match(/<[embed|embed].*?src=[\'|\"](.*?(?:[\.mp3|\.ogg|\.wav]))[\'|\"].*?[\/]?>/ig);  //content.replace(/<[embed|embed].*?src=[\'|\"](.*?(?:[\.mp3|\.ogg|\.wav]))[\'|\"].*?[\/]?>/ig, ",");

    var html = content;
    if(html_audio != null){
        if(html_audio.length > 0){
            var img_name = '';
            for(var i=0;i<html_audio.length;i++){
                img_name = html_audio[i].match(/<embed.*src\s*=\s*[\"|\']?\s*([^>\"\'\s]*)/i);
                if(img_name.length >= 2){
                    html = html.replace(html_audio[i],'<div onclick="bind_play(this,'+i+')" id="audio_div'+i+'" class="audioplay"><img src="/wapi/img/play.png"/><input type="hidden" name="audio_src" value="'+img_name[1]+'" /></div>');
                }
            }
        }
    }
    $('#activity_content').html(html);

//    $.get("https://open.weixin.qq.com/connect/oauth2/authorize?appid=<!--{$appid}-->&redirect_uri=<!--{$url_}-->&response_type=code&scope=snsapi_base&state=1#wechat_redirect");

    function bind_play(obj,num){
        var pli = $(obj);
        var index = $("#activity_content div").index(pli);
        if(pli.attr('class') == 'audioplay playing'){
            pli.removeClass('playing');
            if($('#audio_'+index).get(0)){
                $('#audio_'+index).get(0).pause();
            }
            pli.children('img').attr('src','/wapi/img/play.png');
        }else{
            pli.addClass('playing');
            var a_src = pli.find('input[name=audio_src]').val();
            var point = a_src.lastIndexOf(".");
            var type = a_src.substr(point);
            var a_type = 'mpeg';
            if(type == '.wav'){
                a_type = 'wav';
            }else if(type == '.ogg'){
                a_type = 'ogg';
            }else if(type == '.mp3'){
            }else{
                $('.error_pop').text('您的浏览器不支持播放该歌曲').show();
                return false;
            }

            var playnum = 0;
            for(var a=0;a< $('audio').length;a++){
                if(!$('audio')[a].paused){
                    playnum = a;
                    $('audio')[a].pause();
                    if(a!=num){
                        $('#audio_div'+a).removeClass('playing');
                        $('#audio_div'+a).children('img').attr('src','/wapi/img/play.png');
                    }
                }
            }
            var audioHtml = '<audio id="audio_' + index +'" controls="controls" preload="auto"><source src="'+ a_src +'"></source></audio>';

            if(!$('#audio_'+index)[0]){
                $("#audio_div").append(audioHtml);
            }
            $('#audio_'+index).hide();
            pli.children('img').attr('src','/wapi/img/stop.png');
            $('#audio_'+index).get(0).play();
        }
    }
</script>

</body>
</html>
